package com.hsteach.enums;

import com.hsteach.common.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * <p>
 *
 * </p>
 *
 * @author mgb
 * @version StatusEnum, java v1.0 2023-11-20 0:11 EXP $
 */
@Getter
@AllArgsConstructor
public enum SourceEnum {
    WEB(0, "web端"),
    APP(1, "app端");

    private int code;
    private String desc;

    public static SourceEnum getInByCode(Integer code){
        SourceEnum statusEnum = Arrays.stream(SourceEnum.values()).filter(e -> e.getCode()==(code)).findFirst().orElse(null);
        if (statusEnum == null) {
            throw new ServiceException("不存在的状态值");
        }
        return statusEnum;
    }
}
